package edu.chalmers.trec;

import org.cocos2d.nodes.CCLabel;
import org.cocos2d.nodes.CCNode;
import org.cocos2d.nodes.CCSprite;
import org.cocos2d.types.CGPoint;
import org.cocos2d.types.CGRect;

import edu.chalmers.targine.ARManager;
import edu.chalmers.targine.CocosComponent;

public class CombatStats implements CocosComponent {
	private CCNode _anchor;
	private CCSprite _sword, _shield;
	private CCLabel _defenceText, _attackText;
	private int _defence, _attack;
	
	public CombatStats(){
		_defence = 0;
		_attack = 0;
		_anchor = CCNode.node();
		_sword = CCSprite.sprite("icon_sword.png");
		_shield = CCSprite.sprite("icon_shield.png");
		_defenceText = CCLabel.makeLabel("0", "Consolas", 30f);
		_attackText = CCLabel.makeLabel("0", "Consolas", 30f);
		_sword.setPosition(0f, 0f);
		_attackText.setPosition(64f, 0f);
		_shield.setPosition(180f, 0f);
		_defenceText.setPosition(244f, 0f);
		_anchor.addChild(_sword);
		_anchor.addChild(_shield);
		_anchor.addChild(_defenceText);
		_anchor.addChild(_attackText);
		_anchor.setPosition(850, 64f);
	}

	public void update(float dt, ARManager arManager) {
		// TODO Auto-generated method stub
		
	}
	
	public void addAttack(int attack){
		_attack += attack;
		_attackText.setString(""+_attack);
	}
	
	public void addDefence(int defence){
		_defence += defence;
		_defenceText.setString(""+_defence);
	}
	
	public void reset(){
		_attack = 0;
		_defence = 0;
		_attackText.setString("0");
		_defenceText.setString("0");
	}

	public boolean isIntersecting(CGRect fingerRect) {
		// TODO Auto-generated method stub
		return false;
	}

	public void touchBegan(int touchID, CGPoint touchPoint) {
		// TODO Auto-generated method stub
	}

	public void updateTouch(int touchID, CGPoint touchPoint) {
		// TODO Auto-generated method stub
		
	}

	public boolean hasTouchID(int touchID) {
		// TODO Auto-generated method stub
		return false;
	}

	public void touchEnded(int touchID, ARManager arManager) {
		// TODO Auto-generated method stub
	}

	public CCNode getNode() {
		return _anchor;
	}

	public void setVisible(boolean visible) {
		_anchor.setVisible(visible);
	}

	public boolean isVisible() {
		return _anchor.getVisible();
	}

}
